package com.czxy.dao;

import com.czxy.domain.Qian;
import com.czxy.domain.User;
import com.czxy.utils.MyBatisUtils;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author 嗨皮骚
 * @version v 1.0
 * @date 2019/5/9
 */
public class QianDao {
    public void add(Qian qian) {

        QianDaoMapper mapper = MyBatisUtils.getMapper(QianDaoMapper.class);
        int i = mapper.insetQianDao(qian);
        int i1 = mapper.updateUserQdnum(qian);
        MyBatisUtils.commitAndClose();

    }

    public List<Qian> findQianDaoByUid(String uid) {
        QianDaoMapper mapper = MyBatisUtils.getMapper(QianDaoMapper.class);
        List<Qian>qians=mapper.findQianDaoByUid(uid);
        MyBatisUtils.close();
        return qians;
    }

    public List<Qian> findQianDaoByUidDate(Qian qian) {
        QianDaoMapper mapper = MyBatisUtils.getMapper(QianDaoMapper.class);
        List<Qian> qians=mapper.findQianDaoByUidDate(qian);
        MyBatisUtils.close();
        return qians;
    }

    public int userQianDaoNum(User loginUser) {
        QianDaoMapper mapper = MyBatisUtils.getMapper(QianDaoMapper.class);
        int i=mapper.userQianDaoNum(loginUser);
        MyBatisUtils.close();
        return i;
    }


    public void upDatabaseDate(int y, int i) {
        QianDaoMapper mapper = MyBatisUtils.getMapper(QianDaoMapper.class);
        String yy=y+"";
        String mm=i+"";
        mapper.upDatabaseDate(yy, mm);
        MyBatisUtils.commitAndClose();
    }
}
